package com.soft.service;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;

import com.soft.entity.Dept;
import com.soft.service.DeptService; // 补充 DeptService 的导入（根据注入逻辑推断）

@SpringBootTest
public class DeptServiceTest {

    @Autowired
    private DeptService deptService;

   // @Test
    public void queryAllTest() {
        List<Dept> deptList = deptService.queryAll();
        Assert.notEmpty(deptList, "为空");
        Assert.isTrue(deptList.size()>0, "数据有值");
        for (int i = 0; i < deptList.size(); i++) {
            System.out.println(deptList.get(i).getDeptno());
        }
    }
    //@Test
    public void queryByLocTest()
    {
    	List<Dept> deptList = deptService.queryByLoc("雄安");
    	Assert.isTrue(deptList.size() == 1, "根据lco进行查询结果的数据不对");
    }
    @Test
    public void insertOneTest() {
    	int num = deptService.insertOne("事业一部", "秦皇岛");
    	Assert.isTrue(num == 1, "增加数据错误");
    }
    //@Test
    public void deleteByIdTest()
    {
    	int num = deptService.deleteById("1");
    	Assert.isTrue(num == 1, "删除数据错误");
    }
    //@Test
    public void deleteByNameTest()
    {
    	int num = deptService.deleteByName("事业一部");
    	Assert.isTrue(num == 1, "删除数据错误");
    }
    //@Test
    public void updateByDnoTest()
    {
    	int num = deptService.updateByDno("3");
    	Assert.isTrue(num == 1, "更新数据错误");
    }
}